package com.handydata.antifraud.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.handydata.common.convert.CommonBeanConvertor;
import com.handydata.common.web.AbsController;

import com.handydata.antifraud.common.exception.RejectCityBasedataExCode;
import com.handydata.antifraud.bo.rejectcitybasedata.RejectCityBasedataReqBO;
import com.handydata.antifraud.bo.rejectcitybasedata.RejectCityBasedataResBO;
import com.handydata.antifraud.vo.rejectcitybasedata.CreateRejectCityBasedataReqVO;
import com.handydata.antifraud.vo.rejectcitybasedata.CreateRejectCityBasedataResVO;
import com.handydata.antifraud.vo.rejectcitybasedata.DeleteRejectCityBasedataReqVO;
import com.handydata.antifraud.vo.rejectcitybasedata.DeleteRejectCityBasedataResVO;
import com.handydata.antifraud.vo.rejectcitybasedata.ModifyRejectCityBasedataReqVO;
import com.handydata.antifraud.vo.rejectcitybasedata.ModifyRejectCityBasedataResVO;
import com.handydata.antifraud.vo.rejectcitybasedata.RejectCityBasedataBeanVO;
import com.handydata.antifraud.vo.rejectcitybasedata.QueryRejectCityBasedataReqVO;
import com.handydata.antifraud.vo.rejectcitybasedata.QueryRejectCityBasedataResVO;
import com.handydata.antifraud.service.RejectCityBasedataService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RequestMapping("/rejectcitybasedata")
@RestController
public class RejectCityBasedataController extends AbsController {
	
	private static final Logger logger = LoggerFactory.getLogger(RejectCityBasedataController.class);
	
	@Autowired
	private RejectCityBasedataService rejectCityBasedataService;
	
	@ApiOperation(value="新增拒绝城市码表", notes="新增拒绝城市码表")
	@ApiImplicitParam(name = "req", value = "新增拒绝城市码表请求对象", required = true, dataType = "CreateRejectCityBasedataReqVO", paramType = "body")
	@PostMapping("/create")
	public CreateRejectCityBasedataResVO createRejectCityBasedata(@RequestBody CreateRejectCityBasedataReqVO req) {
		try {
			logger.info("Execute createRejectCityBasedata, param is {}", req);
			RejectCityBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectCityBasedataReqBO.class);
			RejectCityBasedataResBO resBO = rejectCityBasedataService.createRejectCityBasedata(reqBO);
			CreateRejectCityBasedataResVO res = CommonBeanConvertor.convert(resBO, CreateRejectCityBasedataResVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, CreateRejectCityBasedataResVO.class, req, RejectCityBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}

	@ApiOperation(value="修改拒绝城市码表", notes="修改拒绝城市码表")
	@ApiImplicitParam(name = "req", value = "修改拒绝城市码表请求对象", required = true, dataType = "ModifyRejectCityBasedataReqVO", paramType = "body")
	@PostMapping("/modify")
	public ModifyRejectCityBasedataResVO modifyRejectCityBasedata(@RequestBody ModifyRejectCityBasedataReqVO req) {
		try {
			logger.info("Execute modifyRejectCityBasedata, param is {}", req);
			RejectCityBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectCityBasedataReqBO.class);
			RejectCityBasedataResBO resBO = rejectCityBasedataService.modifyRejectCityBasedata(reqBO);
			ModifyRejectCityBasedataResVO res = CommonBeanConvertor.convert(resBO, ModifyRejectCityBasedataResVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, ModifyRejectCityBasedataResVO.class, req, RejectCityBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}

	@ApiOperation(value="删除拒绝城市码表", notes="删除拒绝城市码表")
	@ApiImplicitParam(name = "req", value = "修改拒绝城市码表请求对象", required = true, dataType = "DeleteRejectCityBasedataReqVO", paramType = "body")
	@PostMapping("/remove")
	public DeleteRejectCityBasedataResVO deleteRejectCityBasedata(@RequestBody DeleteRejectCityBasedataReqVO req) {
		try {
			logger.info("Execute deleteRejectCityBasedata, param is {}", req);
			RejectCityBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectCityBasedataReqBO.class);
			RejectCityBasedataResBO resBO = rejectCityBasedataService.deleteRejectCityBasedata(reqBO);
			DeleteRejectCityBasedataResVO res = CommonBeanConvertor.convert(resBO, DeleteRejectCityBasedataResVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, DeleteRejectCityBasedataResVO.class, req, RejectCityBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}
	
	@ApiOperation(value="查询拒绝城市码表", notes="查询拒绝城市码表")
	@ApiImplicitParam(name = "req", value = "查询拒绝城市码表请求对象", required = true, dataType = "QueryRejectCityBasedataReqVO", paramType = "body")
	@PostMapping("/query")
	public QueryRejectCityBasedataResVO queryRejectCityBasedata(@RequestBody QueryRejectCityBasedataReqVO req) {
		try {
			logger.info("Execute queryRejectCityBasedata, param is {}", req);
			RejectCityBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectCityBasedataReqBO.class);
			RejectCityBasedataResBO resBO = rejectCityBasedataService.queryRejectCityBasedata(reqBO);
			QueryRejectCityBasedataResVO res = CommonBeanConvertor.convert(resBO, QueryRejectCityBasedataResVO.class, RejectCityBasedataBeanVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, QueryRejectCityBasedataResVO.class, req, RejectCityBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}
	
}
